program StochasticSimulation;
{$APPTYPE CONSOLE}

uses
  SysUtils,
  Classes,
  ODEModel in 'ODEModel.pas',
  ODEIntegrator in 'ODEIntegrator.pas',
  RungeKutta in 'RungeKutta.pas',
  StochasticProcess in 'StochasticProcess.pas',
  StochasticTest in 'StochasticTest.pas',
  Helper in 'Helper.pas';

{$R *.res}

var
  integrator, integrator2 : TODEIntegrator;
  DensePoints : Vector;
  TimeStart, TimeEnd, Step : extended;
  numberOfDensePoints : integer;
  i : integer;

  process1, process2 : TStochasticProcess;
  process1test, process2test: TShochasticTest;

  report : TextFile;

  D, L, w0 : extended;
begin

{
  TimeStart := 0;

  D := 9;
  L := 10;

  TimeEnd := (1/L)*300;

  Randomize();

  numberOfDensePoints := 500;
  Step := (TimeEnd-TimeStart)/numberOfDensePoints;

  setLength(DensePoints, numberOfDensePoints);
  for i := 0 to numberOfDensePoints do
      DensePoints[i] := Step * i;

  integrator := TRungeKutta45.Create(1e-14, step, timeStart, timeEnd, densePoints);
  process1 := TStochasticProcess1.Create(integrator, D, L);
  process1.Run();

  process1test := TStochasticTest1.Create(process1, step, 0, D, L);
  process1test.TestName := 'test2';

  process1test.RunTest(0.90);
  }

  TimeStart := 0;

  D := 9;
  L := 1000;
  w0 := Pi/50;

  TimeEnd := (L/(sqr(L) + sqr(w0)))*200;
  Randomize();

  numberOfDensePoints := 1000;
  Step := (TimeEnd-TimeStart)/numberOfDensePoints;

  setLength(DensePoints, numberOfDensePoints);
  for i := 0 to numberOfDensePoints do
      DensePoints[i] := Step * i;

  integrator := TRungeKutta45.Create(1e-14, step, timeStart, timeEnd, densePoints);
  process2 := TStochasticProcess2.Create(integrator, D, L, w0);
  process2.Run();

  AssignFile(report, 'process2.txt');
  Rewrite(report);

  for i := 0 to (Length(process2.Y)-1) do
  begin
          writeln(report,
            FloatToStr(i*Step) + ' '
            + FloatToStr(process2.Get(i))
            );
  end;

  CloseFile(report);

  process2test := TStochasticTest2.Create(process2, step, 0, D, L, w0);
  process2test.TestName := 'test2';

  process2test.RunTest(0.9);

  readln;
end.
